import NetWork from '@Config/server/api/base'

/***
 * @description 查看我的备份文件夹
 *
 */
export const favoriteList = async (_data) => {
  let work = await NetWork('/favorite/list', {
    body: JSON.stringify(_data),
  })
  //把备份文件夹，归为文件夹显示方式
  work.data?.records?.map((x) => {
    x.local_loading = false
    x.fileType = 0
    x.pid = 0
    x.name = x.title
    return x
  })
  return work
}

//（开发中）备份文件到备份文件夹
export const favoriteAddFile = async (_data) => {
  let work = await NetWork('/favorite/addFile', {
    body: JSON.stringify(_data),
  })

  return work
}

//新增修改备份文件夹，新增id=0
export const favoriteAdd = async (_data) => {
  let work = await NetWork('/favorite/add', {
    body: JSON.stringify(_data),
  })

  if (work.code == 0) {
    work.data.local_loading = false
    work.data.fileType = 0
    work.data.pid = 0
    work.data.name = work.data.title
  }
  return work
}

///删除备份文件夹
export const favoriteDel = async (_data) => {
  let work = await NetWork('/favorite/del', {
    body: JSON.stringify(_data),
  })

  return work
}

///favorite/fileList

///查看备份文件夹的文件
export const favoriteFileList = async (_data) => {
  let work = await NetWork('/favorite/fileList', {
    body: JSON.stringify(_data),
  })
  return work
}

///文件取消备份
export const favoriteDelFile = async (_data) => {
  let work = await NetWork('/favorite/delFile', {
    body: JSON.stringify(_data),
  })
  return work
}
